<% crlf=CHR(13)+CHR(10) SET DATe YMD SET MARK TO [-] SET CENTURY ON SET CENTURY ON IF TYPE([oprop])=[O] oprophome=addbs(oprop.appstartpath) ELSE oprophome=[d:\shahprjs\supermarket\mh\] endif m_transid=orequest.form('thetransid') m_printdoc=orequest.form('printdoc') if isnull(m_transid) m_transid=orequest.querystring('t') endif if isnull(m_printdoc) m_printdoc=orequest.querystring('a') endif *theuser=orequest.querystring('user') pagetype=lower(transform(orequest.querystring('pw'))) * 80mm * * * * * *@page {size: | auto | [ || [ landscape | portrait ] ]} do case *case pagetype='poslocal' *case pagetype='posmix' case pagetype='pos' pagewidth='8cm' pageheight='auto' case pagetype='a4' pagewidth='8.3inch' pageheight='11.7inch' case pagetype='a5' pagewidth='5.8inch' pageheight='8.3inch' case pagetype='a6' pagewidth='4.1inch' pageheight='5.8inch' OTHER pagewidth='8.3inch' pageheight='11.7inch' endcase theuser=[] tsql=[select * from ("]+dbclocation+[visits.dbf") where allt(transid)==']+allt(m_transid)+[' into cursor maincursor] &tsql thepatientid=allt(patientid) tsql=[select * from ("]+dbclocation+[patients.dbf") where allt(patientid)==']+allt(thepatientid)+[' into cursor ptcursor] &tsql today=ptcursor.birth thedate=today store 0 to totaldays, totalmonths, totalyears if not empty(thedate) currentdate=date() totaldays=day(currentdate)-day(thedate) if totaldays<0 totaldays=currentdate-GOMONTH(currentdate,-1) totalmonths=month(GOMONTH(currentdate,-1))-MONTH(thedate) totalyears=YEAR(GOMONTH(currentdate,-1))-YEAR(thedate) IF totalmonths<0 totalmonths=totalmonths+12 totalyears=totalyears-1 ENDIF ELSE totalmonths=month(currentdate)-MONTH(thedate) totalyears=YEAR(GOMONTH(currentdate,-1))-YEAR(thedate) IF totalmonths<0 totalmonths=totalmonths+12 totalyears=totalyears-1 ENDIF ENDIF endif ***This portion will get test data and will formate it as needed *possible groups *Actual test data tsql=[select val(x.testid) as vtest,x.testid,x.result, y.testname, y.unit, y.groupname, y.range,y.g from ("]+dbclocation+[lab.dbf") x inner join ] tsql=tsql+[ (']+oprophome+[temp\labmaster') y ON(x.testid=y.testid) where allt(x.transid)==']+allt(m_transid)+[' ] tsql=tsql+[ order by vtest into cursor labcursor readwrite ] &tsql INDEX on vtest TAG vtest LOCATE FOR g='A' IF NOT EOF() tsql=[select * FROM (']+oprophome+[temp\labmaster') where testid NOT in (select testid FROM (']+dbclocation+[lab.dbf') where transid=']+m_transid+[') AND g='A' into cursor xcursor ] &tsql tdbf=DBF() SELECT [labcursor] APPEND FROM (tdbf) endif LOCATE FOR g='B' IF NOT EOF() tsql=[select * FROM (']+oprophome+[temp\labmaster') where testid NOT in (select testid FROM (']+dbclocation+[lab.dbf') where transid=']+m_transid+[' ') AND g='B' into cursor xcursor ] &tsql tdbf=DBF() SELECT [labcursor] APPEND FROM (tdbf) endif LOCATE FOR g='C' IF NOT EOF() tsql=[select * FROM (']+oprophome+[temp\labmaster') where testid NOT in (select testid FROM (']+dbclocation+[lab.dbf') where transid=']+m_transid+[' ) AND g='C' into cursor xcursor ] &tsql tdbf=DBF() SELECT [labcursor] APPEND FROM (tdbf) endif select [labcursor] GO top tstr=[] DO WHILE NOT EOF() thisgroup=g thistest=testid tgroupname=groupname firstline=.t. DO WHILE groupname=tgroupname AND g=thisgroup if not (empty(result) and empty(g)) tstr=tstr+[] IF firstline tstr=tstr+[] firstline=.f. ELSE tstr=tstr+[] ENDIF tstr=tstr+[] endif skip enddo enddo tstr=tstr+[
IDENTITYTESTRESULTRESULTUNITRANGE
]+tgroupname+[ ]+TESTNAME+[]+IIF(EMPTY(result),' ',ALLTRIM(result))+[]+IIF(EMPTY(unit),' ',ALLTRIM(unit))+[]+IIF(EMPTY(range),' ',ALLTRIM(range))+[
] *** select [ptcursor] %>

<%=xcompany.name%>

<%=allt(allt(xcompany.address1)+[ ]+allt(xcompany.address2))%>

ENTRY TOKEN <%=maincursor.transid%>

<%if m_printdoc='token'%>
<%if not empty(maincursor.solution)%> <%endif%>
Entry:<%=transform(maincursor.dtime)%> <%=icase(ptcursor.gender='m','GENDER: MALE',ptcursor.gender='F','GENDER: FEMALE','')%>
Speciman:<%=allt(maincursor.speciman)%>
Patient:<%=ptcursor.name%> <%=iif(totaldays<1 or totalyears>2,'','DAYS: '+transform(totaldays))%> <%=iif(totalmonths<1 or totalyears>2,'','MONTHS: '+transform(totalmonths))%> <%=iif(totalyears<1,'','YEARS: '+transform(totalyears))%> <%=iif(empty(ptcursor.weight),'','WEIGHT: '+transform(ptcursor.weight))%>
Ref. By:<%=maincursor.doctor%>
Opinion<%=allt(maincursor.solution)%>
<%endif%> <%=tstr%>